package com.zzptc.tkfate;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;


public class RegActivity extends AppCompatActivity {
    Button btn_lo;
    EditText en_ho;
    Button btn_gt;
    EditText en_yu;
    private static final String TAG = "RegActivity";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_reg);

        init();
        event();
    }
    public void event(){
        btn_lo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Log.d(TAG,"你打了我");
                //准备回传 1.获取值 2.保存值到意图 3.回传
                String usenhot = en_ho.getText().toString().trim();
                String password = en_yu.getText().toString().trim();
                if (usenhot.equals("") || password.equals("")) {
                    Toast.makeText(RegActivity.this, "用户名或密码不能为空", Toast.LENGTH_SHORT).show();
                } else {
                    Log.d(TAG, usenhot);
                    Intent intent = new Intent();
                    intent.putExtra("usenho", usenhot);
                    intent.putExtra("yu", password);
                    setResult(3, intent);
                    finish();
                }
            }
        });
    }


    public void init(){
        btn_lo=findViewById(R.id.btn_lo_ok);
        en_ho=findViewById(R.id.en_ho_ok);
        btn_gt=findViewById(R.id.btn_gt_ok);
        en_yu=findViewById(R.id.en_yu_ok);
    }
}
